import { loadPlugin, loadPluginFn } from '../../app/config/loadplugin.config.js';
import authService from '../../app/resolves/authService.js';
import getCourseList from '../../course/resolves/getCourseList.js';
import getRunnerDetail from '../resolves/getRunnerDetail.js';

import getGroupaliasList from '../resolves/getGroupaliasList.js';
import getGroupaliasDetail from '../resolves/getGroupaliasDetail.js';

import getGroupList from '../resolves/getGroupList.js';
import getGroupDetail from '../resolves/getGroupDetail.js'

import getTeamList from '../resolves/getTeamList.js';
import getTeamDetail from '../resolves/getTeamDetail.js';
import getTeamRunner from '../resolves/getTeamRunner.js';

import runnerHtml from 'ngtemplate!html!../../../tpls/runner/runner.html';
import runnerListHtml from 'ngtemplate!html!../../../tpls/runner/runner.list.html';
import runnerImportHtml from 'ngtemplate!html!../../../tpls/runner/runner.import.html';

import groupHtml from 'ngtemplate!html!../../../tpls/group/group.html';
import grouplistHtml from 'ngtemplate!html!../../../tpls/group/group.list.html';

import groupaliasHtml from 'ngtemplate!html!../../../tpls/groupalias/groupalias.html';
import groupaliaslistHtml from 'ngtemplate!html!../../../tpls/groupalias/groupalias.list.html';

import teamHtml from 'ngtemplate!html!../../../tpls/team/team.html';
import teamlistHtml from 'ngtemplate!html!../../../tpls/team/team.list.html';


/**
 * RunnerRouter - config
 * 赛事模块路由设置
 */
function RunnerRouter($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider, $ocLazyLoadProvider) {

	//set router
    $stateProvider

		// 导入参赛选手信息
		.state('dashboard.race.runnerimport', {
		    url: '/runner/import',
		    data: { 
		        pageTitle: '导入参赛选手信息' 
		    },
		    templateUrl: runnerImportHtml,
		    controller: 'RunnerImportController as vm',
		    resolve: {
		    	authService: authService,
		    	loadPlugin: loadPluginFn([loadPlugin.dropzone])
		    }
		})

		// 新建参赛选手信息
		.state('dashboard.race.runner', {
		    url: '/runner',
		    data: { 
		        pageTitle: '新建参赛选手信息' 
		    },
		    templateUrl: runnerHtml,
		    controller: 'RunnerController as vm',
		    resolve: {
		    	authService: authService,
		    	getCourseList: getCourseList,
		    	loadPlugin: loadPluginFn([loadPlugin.icheck, loadPlugin.blink])
		    }
		})

		// 参赛选手信息列表
		.state('dashboard.race.runnerlist', {
		    url: '/runner/list',
		    data: { 
		        pageTitle: '参赛选手信息列表' 
		    },
		    templateUrl: runnerListHtml,
		    controller: 'RunnerListController as vm',
		    resolve: {
		    	authService: authService,
		    	loadPlugin: loadPluginFn(loadPlugin.dataTables)
            }
		})

		// 编辑参赛选手信息
		.state('dashboard.race.runneredit', {
		    url: '/runner/edit?runner_id',
		    data: { 
		        pageTitle: '编辑参赛选手信息' 
		    },
		    templateUrl: runnerHtml,
		    controller: 'RunnerEditController as vm',
		    resolve: {
		    	authService: authService,
		    	getRunnerDetail: getRunnerDetail,
		    	getCourseList: getCourseList,
		    	loadPlugin: loadPluginFn([loadPlugin.icheck, loadPlugin.blink])
		    }
		})

		// 分组列表
		.state('dashboard.race.groupaliaslist', {
		    url: '/groupalias/list',
		    data: { 
		        pageTitle: '分组列表' 
		    },
		    templateUrl: groupaliaslistHtml,
		    controller: 'GroupaliasListController as vm',
		    resolve: {
		    	authService: authService,
		    	getGroupaliasList: getGroupaliasList
		    }
		})

		// 新增分组
		.state('dashboard.race.groupalias', {
		    url: '/groupalias?group_name',
		    data: { 
		        pageTitle: '新增分组' 
		    },
		    templateUrl: groupaliasHtml,
		    controller: 'GroupaliasController as vm',
		    resolve: {
		    	authService: authService,
		    	loadPlugin: loadPluginFn([loadPlugin.blink])
		    }
		})

		// 编辑分组
		.state('dashboard.race.groupaliasedit', {
		    url: '/groupalias/edit?aid',
		    data: { 
		        pageTitle: '编辑分组' 
		    },
		    templateUrl: groupaliasHtml,
		    controller: 'GroupaliasEditController as vm',
		    resolve: {
		    	authService: authService,
		    	getGroupaliasDetail: getGroupaliasDetail,
		    	loadPlugin: loadPluginFn([loadPlugin.blink])
		    }
		})

		// 小组列表
		.state('dashboard.race.grouplist', {
		    url: '/group/list',
		    data: { 
		        pageTitle: '小组列表' 
		    },
		    templateUrl: grouplistHtml,
		    controller: 'GroupListController as vm',
		    resolve: {
		    	authService: authService,
		    	getGroupList: getGroupList,
		    	getGroupaliasList: getGroupaliasList
		    }
		})

		// 新增小组
		.state('dashboard.race.group', {
		    url: '/group',
		    data: { 
		        pageTitle: '新增小组' 
		    },
		    templateUrl: groupHtml,
		    controller: 'GroupController as vm',
		    resolve: {
		    	authService: authService,
		    	getCourseList: getCourseList,
		    	getGroupaliasList: getGroupaliasList,
		    	loadPlugin: loadPluginFn([loadPlugin.blink])
		    }
		})

		// 编辑小组
		.state('dashboard.race.groupedit', {
		    url: '/group/edit?group_id',
		    data: { 
		        pageTitle: '编辑小组' 
		    },
		    templateUrl: groupHtml,
		    controller: 'GroupEditController as vm',
		    resolve: {
		    	authService: authService,
		    	getCourseList: getCourseList,
		    	getGroupaliasList: getGroupaliasList,
		    	getGroupDetail: getGroupDetail,
		    	loadPlugin: loadPluginFn([loadPlugin.blink])
		    }
		})

		// 团队列表
		.state('dashboard.race.teamlist', {
		    url: '/team/list',
		    data: { 
		        pageTitle: '团队列表' 
		    },
		    templateUrl: teamlistHtml,
		    controller: 'TeamListController as vm',
		    resolve: {
		    	authService: authService,
		    	getTeamList: getTeamList
		    }
		})

		// 新增团队
		.state('dashboard.race.team', {
		    url: '/team',
		    data: { 
		        pageTitle: '新增团队' 
		    },
		    templateUrl: teamHtml,
		    controller: 'TeamController as vm',
		    resolve: {
		    	authService: authService,
		    	getCourseList: getCourseList,
		    	loadPlugin: loadPluginFn([loadPlugin.blink])
		    }
		})

		// 编辑团队
		.state('dashboard.race.teamedit', {
		    url: '/team/edit?team_id',
		    data: { 
		        pageTitle: '编辑团队' 
		    },
		    templateUrl: teamHtml,
		    controller: 'TeamEditController as vm',
		    resolve: {
		    	authService: authService,
		    	getCourseList: getCourseList,
		    	getTeamDetail: getTeamDetail,
		    	getTeamRunner: getTeamRunner,
		    	loadPlugin: loadPluginFn([loadPlugin.blink])
		    }
		});

}

RunnerRouter.$inject = ['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', '$ocLazyLoadProvider'];

export default RunnerRouter; 